#include<windows.h>
#include<bits/stdc++.h>
#include<urlmon.h>
#include<wininet.h>
int main(){
	SetWindowPos(GetConsoleWindow(),HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW);
	printf("Mouse Clicker 更新工具\n");
	printf("本工具将引导您完成更新.\n");
	system("pause");
	system("cls");
	printf(">第一步:终止运行\n");
	printf("如果您打开了MouseClicker,请保证您准备好了再点击下一步.\n");
	system("pause");
	ShellExecute(0,"runas","cmd.exe"," /c taskkill /im MouseClicker.exe /t /f",0,0);
	printf(">正在下载,从gitee码云下载资源\n");
//	system("curl.exe --output MouseClicker1.exe --url https://gitee.com/haozexu/MouseClicker/releases/download/V8.0/MouseClicker.exe");
	DeleteUrlCacheEntry(TEXT("https://gitee.com/haozexu/MouseClicker/releases/download/V8.0/MouseClicker.exe"));
	HRESULT re=URLDownloadToFile(0,TEXT("https://gitee.com/haozexu/MouseClicker/releases/download/V8.0/MouseClicker.exe"),TEXT(".\\MouseClicker1.exe"),0,0);
	if(re==S_OK){
		printf("成功!");
	}
	printf("=>下载完成,正在清除旧版本");
	system("del MouseClicker.exe");
	system("ren MouseClicker1.exe MouseClicker.exe");
	printf("更新进程完毕.");
	system("pause");
	return 0;
}